#include <cmath>
#include <iostream>

using namespace std;

double mcnormal_vs(double x)
{
	const double G = 0.2316419;
	const double PI = 3.1415926;

	// constants: from a_5 to a_1
	const double A[5] = { 1.330274429, -1.821255978,
						  1.781477937, -0.356563782,
						  0.319381530 };

	if (x < 0)
		return 1 - mcnormal_vs(-x);

	double nprime = exp(-x*x/2)/sqrt(2*PI);

	double k = 1/(1 + G*x);

	double poly = 0;

	for (int i = 0; i < 5; i++)
		poly = k*poly + A[i];
	
	poly *= k;

	return 1 - nprime*poly;
}	
